﻿





using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DrawableObjects.Actors.Aircrafts;
using WorldView;
using Sirian.DrawableObject.Actors;
using DrawableObjects.Actors;
using Microsoft.Xna.Framework;

namespace Serialization.Script
{
    /// <summary>
    /// An event that is called whenever a wave of enemy aircrafts is created.
    /// </summary>
    public class Event_CreateEnemyWave : ScriptedEvent
    {
        private List<Aircraft> enemyList
        {
            get;
            set;
        }

        private Path path
        {
            get;
            set;
        }

        private Formation formation
        {
            get;
            set;
        }


        /// <summary>
        /// Adds the aircrafts to the world after passing some parameters to them.
        /// </summary>
        /// <param name="world">The world to insert the aircraft into.</param>
        /// <param name="visibleArea">The visible area bounding.</param>
        /// <param name="useableArea">The usable area where the wave can be inserted into.</param>
        public void execute(World world, Bounding visibleArea, Bounding useableArea)
        {
            foreach (Aircraft aircraft in enemyList)
            {
                aircraft.standardRotation = Matrix.CreateRotationY((float)Math.PI);
                aircraft.Create +=new GlobalGameClasses.Eventhandler.CreateEventHandler(world.achievementHandler.OnCreate);
                world.addActor(aircraft);
            }
            formation.setFormation(enemyList, path, visibleArea, useableArea);
        }

        public Event_CreateEnemyWave(List<Aircraft> enemyList, Formation formation, Path path, int eventTime)
        {
            this.enemyList = enemyList;
            this.formation = formation;
            this.path = path;
            this.eventTime = eventTime;
        }

        public override int getNumberOfEnemies()
        {
            return enemyList.Count;
        }
    }
}

